<template>
<!-- 候选人 -->
  <div>
    <el-row>
      <el-col :span="24"><div class="grid-content bg-purple-dark">
        <el-button type="primary" @click="AddCandidate" style="margin-left:30px; margin-top:15px;">新建候选人</el-button>
        </div></el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark_2">
            <el-form :inline="true" :model="form" class="demo-form-inline" label-width="80px" style="padding-top:25px">
              <el-form-item label="姓名">
                <el-input v-model="form.candidateName" placeholder="姓名"></el-input>
              </el-form-item>
              <el-form-item label="招聘职位">
                  <el-select v-model="form.positionId" placeholder="请选择" style="width:350px;">
                  <el-option
                      v-for="item in options"
                      :key="item.id"
                      :label="item.tposition.positionName"
                      :value="item.id">
                  </el-option>
                  </el-select>
              </el-form-item>
              &nbsp;&nbsp;&nbsp;
              <el-form-item label="职位性质">
                <el-select v-model="form.postType" placeholder="职位性质">
                  <el-option label="全部" value=""></el-option>
                  <el-option label="全职" value="0"></el-option>
                  <el-option label="兼职" value="1"></el-option>
                  <el-option label="实习" value="2"></el-option>
                  <el-option label="外派" value="3"></el-option>
                  <el-option label="退休返聘" value="4"></el-option>
                </el-select>
              </el-form-item>
              &nbsp;&nbsp;&nbsp;
               <el-form-item label="学历">
                <el-select v-model="form.education" placeholder="学历">
                  <el-option label="全部" value=""></el-option>
                  <el-option label="高中及一下" value="1"></el-option>
                  <el-option label="大专" value="2"></el-option>
                  <el-option label="本科" value="3"></el-option>
                  <el-option label="硕士" value="4"></el-option>
                  <el-option label="博士及以上" value="5"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="申请时间" style="padding-left:10px">
                  <el-date-picker
                    v-model="daterange1"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                  </el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="pendingList" style="margin-left:70px">搜索</el-button>
                <el-button @click="resetQuery">清空</el-button>
                <el-button>导出</el-button>
              </el-form-item>
            </el-form>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="grid-content bg-purple-dark_3">
            <div id="tou">
              <span style=" position: relative;left:100px;top:20px">基本信息</span>
              <span style=" position: relative;left:1000px;top:20px">操作</span>
            </div>
            <div class="tou2" v-for="(item,index) in candidate" :key="index">
              <span style="font-weight:bold;font-size:17px;">{{item.candidateName}}</span>
              <span style="color:#909399;font-size:14px; margin-left: 20px;">{{item.tposition.positionName}}</span>
              <span style="color:#909399;font-size:14px; margin-left: 20px;">{{item.applyForDate}} 申请</span>
              <el-tag type="danger" v-if="item.status==3"  style="margin-left: 30px;">面试中</el-tag>
              <el-tag v-if="item.status==2"  style="margin-left: 30px;">待面试</el-tag>
              <el-tag type="success" v-if="item.status==1" style="margin-left: 30px;">初 筛</el-tag>
              <el-tag type="warning" v-if="item.status==4" style="margin-left: 30px;">面试通过</el-tag>
              <el-tag v-if="item.status==6"  style="margin-left: 30px;">待入职</el-tag>
              <el-tag type="info" v-if="item.status==7"  style="margin-left: 30px;">人才库</el-tag>
              <br/><br/>
              <span style="color:#6c6d6d;font-size:14px;">{{item.sex==1? "男":"女"}} | {{item.age}}岁 | {{item.workExperience==1? "1-3年": item.workExperience==2? "3-5年": item.workExperience==3? "5-10年":"10年以上"}}</span>
              <el-button type="primary" size="small" v-if="item.status==1 || item.status==2 || item.status==7" style="margin-left: 780px;">安排面试</el-button>
              <el-button type="primary" size="small" v-if="item.status==4" style="margin-left: 780px;">发offer</el-button>
              <el-button type="primary" size="small" v-if="item.status==6" style="margin-left: 780px;">确认入职</el-button>
              <el-button style="margin-left:20px;" v-if="item.status==1 || item.status==2 || item.status==3 || item.status==4" type="text" @click="eliminate">淘汰</el-button>
              <el-button style="margin-left:20px;" v-if="item.status==1 || item.status==2 || item.status==3" type="text" >通过</el-button>
              <el-button style="margin-left:20px;" v-if="item.status==6" type="text" >放弃</el-button>
              <br/><br/>
              <span style="color:#6c6d6d;font-size:14px;">{{item.company}} 丨  2028-06至2032-09</span>
              <br/><br/>
              <span style="color:#6c6d6d;font-size:14px;">{{item.school}} 丨 {{item.major}} 丨 {{item.education==1? "高中及以下": item.education==2? "大专": item.education==3? "本科" : item.education==4? "硕士":"博士及以上"}}  2026-09至2028-06</span>
            </div>
            <div class="block">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="pageNum"
                  :page-sizes="[3, 10, 20, 50]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total"
                >
                </el-pagination>
             </div>
              
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data() {
    return {
      form: {
        candidateName:"",
        positionId:"",
        postType:"",
        education:"",
        startDate:"",
        endDate:"",
      },
      dialogTableVisible:false,
      table:"",
      options: [],
      daterange1:[],
      candidate:[],
      pageNum: 1,
      pageSize: 3,
      total: 0,
    };
  },
  created() {
    this.getPMessage();
    this.pendingList();
  },
  methods: {
    AddCandidate(){
      this.$router.push("/AddCandidate"); //添加
    },
    getPMessage(){
        axios.post("TPositionMessage/findPMessageAll")
          .then((res) => {
              console.log(res);
              this.options = res.data;
          })
    },
     //每页条数改变时触发 选择一页显示多少行
      handleSizeChange(val) {
        this.pageSize = val;
        this.pendingList();
      },
      //当前页改变时触发 跳转其他页
      handleCurrentChange(val) {
        this.pageNum = val;
        this.pendingList();
      },
      pendingList() {
      // var a=JSON.parse(localStorage.getItem("user"))
      // this.voteInfo.sponsorId=a.id
      // console.log("aaa:"+this.voteInfo.sponsorId)
      var dateRange3=this.daterange1.length;
      if (dateRange3> 0) {
          this.form.startDate=this.daterange1[0];
          this.form.endDate=this.daterange1[1];
        }
      axios
        .post(
          "TCandidate/findCandidateFenYe?pageNum=" +
            this.pageNum +
            "&pageSize=" +
            this.pageSize,
          this.form
        )
        .then((res) => {
          console.log(res);
          this.candidate = res.data.rows;
          this.total = res.data.total;
        });
    },
    resetQuery(){
      this.form.candidateName="";
      this.form.positionId="";
      this.form.postType="";
      this.form.education="";
      this.daterange1=[];
      this.pendingList();
    },
    eliminate(){

    }
  },
};
</script>

<style scoped>
.block{
  padding-top: 40px;
  padding-left: 800px;
}
.tou2{
  width: 90%;
  height: 150px;
  margin-left: 130px;
  margin-top:60px;
 }
 #tou{
  width: 95%;
  height: 60px;
  background-color: rgb(247, 249, 249);
  margin-left: 30px;
  position: relative;
  top:20px;
 }
 
 .el-row {
    margin-bottom: 20px;
    
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: white;
    height: 70px;
  }
   .bg-purple-dark_2 {
    background: white;
    height: 150px;
  }
   .bg-purple-dark_3 {
    background: white;
    height: 700px;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #6c6d6d;
  }
</style>